/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


public class JDialogConfig extends javax.swing.JDialog {

     public static int porta= 5003;
     public static String ip = "localhost";

 
     public static String getIP(){
         return ip;
     
     }
     
    public JDialogConfig(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jTextIP.setText(ip.toString());
        jTextPorta.setText(String.valueOf(porta));
    
    } 


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jButton1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextPorta = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextIP = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("Ajuste aqui as configurações de comunicação do seu sistema");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 12, -1, -1));

        jLabel2.setText("cliente servidor");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 36, -1, -1));
        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 58, 340, 10));

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 170, -1, -1));

        jLabel4.setText("Número de Porta");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, -1, -1));

        jTextPorta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextPortaActionPerformed(evt);
            }
        });
        getContentPane().add(jTextPorta, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 130, 250, -1));

        jLabel3.setText("Endereço IP");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 90, -1, -1));

        jTextIP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextIPActionPerformed(evt);
            }
        });
        getContentPane().add(jTextIP, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 90, 250, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextIPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextIPActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextIPActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       
        ip = jTextIP.getText();
        porta = Integer.decode(jTextPorta.getText());
      
        this.dispose();
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextPortaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextPortaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextPortaActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JDialogConfig dialog = new JDialogConfig(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextIP;
    private javax.swing.JTextField jTextPorta;
    // End of variables declaration//GEN-END:variables

}
